/**
 * Created by root on 17-1-7.
 */
export default class CSDialog {
    static options = {
        closeButton: true,
        positionClass: "toast-bottom-right"
    };

    static alert(message: string) {
        bootbox.dialog({
            size: "small",
            title: '<h4 id="dbaLoginModalTitle" class="text-center text-danger">警告</h4>',
            message: `<h4 class='text-center' style='font-size:20px'>${message}</h4>`,
            buttons: {
                ok: {
                    label: "确定",
                    className: "btn btn-success"
                }
            }
        });
    }

    static confirm(message: string, sure: ()=>void, notsure?: ()=>void) {
        bootbox.dialog({
            size: "small",
            title: '<h4 id="dbaLoginModalTitle" class="text-center text-danger">警告</h4>',
            message: `<h4 class='text-center' style='font-size:20px'>确认${message}？</h4>`,
            buttons: {
                cancel: {
                    label: "取消",
                    className: "btn btn-danger",
                    callback: function () {
                        if (notsure) notsure();
                    }
                },
                ok: {
                    label: "确定",
                    className: "btn btn-primary",
                    callback: function () {
                        sure();
                    }
                }
            }
        });
    };

    static success(message :string) {
        toastr.options = this.options;
        toastr.success(message);
    };

    static error(message :string) {
        toastr.options = this.options;
        toastr.error(message);
    };

    static info(message :string) {
        toastr.options = this.options;
        toastr.info(message);
    }

    static warning(message :string) {
        toastr.options = this.options;
        toastr.warning(message);
    }
};